package cn.kgc.springhouse.service.impl;

import cn.kgc.springhouse.entity.Houseinfo;
import cn.kgc.springhouse.mapper.HouseinfoMapper;
import cn.kgc.springhouse.service.HouseinfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwr
 * @since 2024-04-09
 */
@Service
public class HouseinfoServiceImpl extends ServiceImpl<HouseinfoMapper, Houseinfo> implements HouseinfoService {

    @Resource
    HouseinfoMapper houseinfoMapper;

    /**
     *
     * @param typeName
     * @param pageNo
     * @return 分页查询
     */
    @Override
    public PageInfo<Houseinfo> selectPageList(String typeName,int pageNo,int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Houseinfo> houseinfos = houseinfoMapper.selectPageList(typeName);
        PageInfo<Houseinfo> pageInfo = new PageInfo<Houseinfo>(houseinfos);
        return pageInfo;
    }

    @Override
    public List<Houseinfo> select2(String typeName) {
        return houseinfoMapper.selectPageList(typeName);
    }

    /**
     * 根据id 查询house信息
     * @param id
     * @return
     */
    @Override
    public Houseinfo getHouseById(Integer id) {
        return houseinfoMapper.getHouseById(id);
    }

    @Override
    public int upadate(Houseinfo houseinfo) {
        return houseinfoMapper.updateById(houseinfo);
    }

    @Override
    public int delete(Houseinfo houseinfo) {
        return houseinfoMapper.deleteById(houseinfo);
    }


}
